<template>
  <ul class="todo-list">
    <!-- completed: 完成的类名 -->
    <li v-for="item in list" :key="item.id" :class="{completed:item.isDone}" >
      <div class="view">
        <input class="toggle" type="checkbox" v-model="item.isDone" />
        <label>{{item.name}}</label>
        <!-- 3.1添加删除的点击事件,删除具体事件，用id -->
        <button class="destroy"
        @click="delFn(item.id)"
        ></button>
      </div>
    </li>
  </ul>
  
</template>

<script>
export default {
  props:['list'],
  methods:{
    //3.2删除的方法
    delFn(id){
      // console.log(id);
      //3.5用this.$emit给父组件传过去
      this.$emit('del',id)
    }
  }
}
</script>